function filename = run_computation_time_o(D, nruns)
%
% Copyright (C) 2014 Chin-Chang Yang
% See the license at https://github.com/SPS-DE/SPS-DE

if matlabpool('size') == 0
	matlabpool('open');
end

load('InitialX.mat');
solvers = {...
	'derand1bin', ...
	'debest1bin', ...
	'dcmaeabin', ...
	'deglbin', ...
	'jadebin', ...
	'rbdebin', ...
	'sadebin', ...
	'shade',};
measureOptions.Dimension = D;
measureOptions.Runs = nruns;
measureOptions.MaxFunEvals = measureOptions.Dimension * 1e4;
measureOptions.LowerBounds = -100;
measureOptions.UpperBounds = 100;
measureOptions.FitnessFunctions = ...
	{'cec14_f1', 'cec14_f2', 'cec14_f3', 'cec14_f4', ...
	'cec14_f5', 'cec14_f6', 'cec14_f7', 'cec14_f8', 'cec14_f9', ...
	'cec14_f10', 'cec14_f11', 'cec14_f12', 'cec14_f13', ...
	'cec14_f14', 'cec14_f15', 'cec14_f16', 'cec14_f17', ...
	'cec14_f18', 'cec14_f19', 'cec14_f20', 'cec14_f21', ...
	'cec14_f22', 'cec14_f23', 'cec14_f24', 'cec14_f25', ...
	'cec14_f26', 'cec14_f27', 'cec14_f28', 'cec14_f29', ...
	'cec14_f30'};
solverOptions.dimensionFactor = 5;
solverOptions.NP = solverOptions.dimensionFactor * measureOptions.Dimension;
solverOptions.F = 0.7;
solverOptions.CR = 0.5;
solverOptions.RecordPoint = 0;
solverOptions.ftarget = -inf;
solverOptions.TolX = -inf;
solverOptions.TolStagnationIteration = Inf;
solverOptions.initial.X = eval(sprintf('XD%dNP%d', ...
	measureOptions.Dimension, ...
	solverOptions.NP));

lb	= measureOptions.LowerBounds * ones(D, 1);
ub	= measureOptions.UpperBounds * ones(D, 1);
maxfes = measureOptions.MaxFunEvals;

rand('state', sum(100*clock)); %#ok<RAND>
startTime = tic;
for isolver = 1 : numel(solvers)
	solver = solvers{isolver};
	fprintf('solver: %s\n', solver);
	for ifitfun = 1 : length(measureOptions.FitnessFunctions)
		fitfun = measureOptions.FitnessFunctions{ifitfun};
		parfor iruns = 1 : nruns
			fprintf('fitfun: %s, iruns: %d\n', ...
				fitfun, iruns);
			feval(solver, ...
				fitfun, ...
				lb, ...
				ub, ...
				maxfes, ...
				solverOptions);
		end
	end
end	
elapsedTime = toc(startTime);
fprintf('elapsedTime: %.2E\n', elapsedTime);
currentDate = datestr(now, 'yyyymmddHHMM');
filename = sprintf('CEC14_Time_o_D%d_%s', D, currentDate);
save(filename, 'elapsedTime', 'D');
end
